package com.njzxw.fs.serverzuul.fitter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.njzxw.fs.commonutil.bean.Common;
import com.njzxw.fs.commonutil.util.RedisUtil;
import com.njzxw.fs.commonutil.web.ReturnMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

public abstract class BaseFilter extends ZuulFilter {

    protected static Logger logger = LoggerFactory.getLogger(MyPreAccessFilter.class);

    @Autowired
    protected Common common;

    @Value("${my.noLogin}")
    protected String[] noLogin;

    @Autowired
    protected ReturnMap returnMap;

    @Autowired
    protected RedisUtil redisUtil;

    /**
     * 是否需要登录
     *
     * @return
     */
    public boolean checkNoLogin(){
        RequestContext ctx = RequestContext.getCurrentContext();
        String url = ctx.getRequest().getRequestURI();

        for(int i=0;i<noLogin.length;i++){
//            logger.debug(";;;;;"+url+"==="+noLogin[i]);
            if(url.contains(noLogin[i])){
                return true;
            }
        }
        return false;

    }

}
